#include <ctime>

#include "metrics/MetricReporter.hpp"

namespace metrics
{
    MetricReporter &MetricReporter::register_collectable(std::shared_ptr<MetricRegistry> registry)
    {
        _registry = registry;
        return *this;
    }

    void MetricReporter::start()
    {
        _running.store(true);
        struct timespec inter
        {
            _interval_sec, _interval_nsec
        };

        while (_running)
        {
            nanosleep(&inter, 0);
            run();
        }
    }

    void MetricReporter::stop()
    {
        _running.store(false);
    }
    
    void MetricReporter::extra_metrics()
    {
        
    }

    MetricReporter &MetricReporter::interval(long int seconds, long int nano_seconds)
    {
        _interval_sec = seconds;
        _interval_nsec = nano_seconds;
        return *this;
    }

} // namespace metrics
